package com.mars;
/*
图文识别
* */

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

public class PictureToWord {
    public static void main(String[] args) {
        //加载待读取图片
        File imageFile = new File("D:\\收藏\\临时下载\\a1.png");
        //创建tess对象
        ITesseract instance = new Tesseract();
        //设置训练文件目录
        instance.setDatapath("D://DataScience//tessdata");
        //设置训练语言
        instance.setLanguage("chi_sim");
        //执行转换
        try {
            String result = instance.doOCR(imageFile);
            System.out.println(result);
        } catch (TesseractException e) {
            e.printStackTrace();
        }
        System.out.println();
    }
}
